GLSP-1635: Migrate test framework from Mocha to Vitest#522
Merged
Conversation
tortmayr
force-pushed
the
GLSP-1635-vitest-migration
branch
2 times, most recently
from
June 22, 2026 22:48
39c94cb to
ba9d270
Compare
Contributor
|
Preview: Removed (PR closed). |
- Replace the Mocha/Chai/nyc/Sinon setup with Vitest: consume the @eclipse-glsp/dev next packages, drop .mocharc/.nycrc, and point all test scripts at `vitest run` - Drive the whole monorepo from a single flat Vitest config at the repo root instead of per-package configs, yielding one merged coverage report - Type-check specs separately via composite tsconfig.test.json projects, since Vitest only transpiles; wire them through a `compile:test` step so `pnpm test` type-checks specs before running them - Import the test API explicitly in every spec (no ambient globals) and load reflect-metadata once via root setup files for the DI specs - Replace the custom expectToThrowAsync helper with Vitest's native rejects.toThrow() / toThrow() matchers and drop the obsolete test-util module - Keep test-only code out of the published packages by excluding specs and test/ helper directories from both the build and the packed files - Switch CI and contributor docs to Vitest: run `pnpm test`, and remove the now-obsolete test-report step and the redundant per-package and :ci test scripts - Clean up leftover tooling artifacts: ignore *.tsbuildinfo so the new per-config build-info is covered, and drop the obsolete nyc/CTRF ignores and clean targets - Run the workflow-standalone example's TS scripts via Node's native type stripping instead of ts-node, which the Mocha toolchain used to provide transitively: convert the scripts to ESM (.mts), drop the ts-node dependency, and raise the Node engine floor to 22.18 where stripping is unflagged Also: - Fix indentation in the local /fix skill doc Part of: eclipse-glsp/glsp#1635
tortmayr
force-pushed
the
GLSP-1635-vitest-migration
branch
from
June 22, 2026 22:56
ba9d270 to
e467f6b
Compare
There was a problem hiding this comment.
Pull request overview
Migrate the monorepo’s test stack from Mocha/Chai/nyc/Sinon to Vitest, centralizing configuration and coverage, updating test sources to the Vitest API, and adjusting tooling/CI/scripts (including the workflow-standalone example) to run without ts-node.
Changes:
- Introduce a single root Vitest/Vite config and new composite
tsconfig.test.jsonprojects wired throughpnpm compile:test. - Update protocol/client specs to use Vitest assertions/mocks/timers and remove obsolete Mocha/nyc configs and helpers.
- Update CI, VS Code launch configs, and workflow-standalone scripts to run under Node’s native TypeScript stripping (Node >= 22.18).
Reviewed changes
Copilot reviewed 77 out of 81 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Adds a flat root Vitest/Vite config for monorepo-wide test/coverage behavior. |
| tsconfig.test.json | Adds root composite TS project for type-checking tests across packages. |
| tsconfig.json | Switches root TS config base away from the Mocha-specific preset. |
| tsconfig.eslint.json | Ensures root Vitest config is included in ESLint TS project. |
| pnpm-workspace.yaml | Updates hoisting patterns and override comments for the new test toolchain. |
| packages/protocol/tsconfig.test.json | Adds protocol test-only composite TS config. |
| packages/protocol/tsconfig.json | Excludes tests from protocol build outputs. |
| packages/protocol/src/utils/uuid.spec.ts | Migrates UUID tests from Chai to Vitest. |
| packages/protocol/src/utils/test-util.ts | Removes obsolete Mocha/Chai async-throw helper utilities. |
| packages/protocol/src/utils/geometry-vector.spec.ts | Migrates vector tests from Chai to Vitest. |
| packages/protocol/src/utils/geometry-movement.spec.ts | Migrates movement tests from Chai to Vitest. |
| packages/protocol/src/utils/function-util.spec.ts | Migrates debounce tests from Sinon fake timers to Vitest timers/mocks. |
| packages/protocol/src/utils/event.spec.ts | Migrates event tests from Sinon/Chai to Vitest. |
| packages/protocol/src/utils/disposable.spec.ts | Migrates disposable tests from Sinon/Chai to Vitest spies/assertions. |
| packages/protocol/src/utils/array-util.spec.ts | Migrates array util tests from Chai to Vitest. |
| packages/protocol/src/sprotty-geometry-point.spec.ts | Migrates point tests from Chai to Vitest. |
| packages/protocol/src/sprotty-geometry-dimension.spec.ts | Migrates dimension tests from Chai to Vitest. |
| packages/protocol/src/di/lazy-injector.spec.ts | Migrates DI tests from Chai to Vitest. |
| packages/protocol/src/di/feature-module.spec.ts | Migrates DI feature-module tests from Chai to Vitest. |
| packages/protocol/src/di/container-configuration.spec.ts | Migrates container configuration tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/viewport.spec.ts | Migrates viewport action tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/undo-redo.spec.ts | Migrates undo/redo tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/tool-palette.spec.ts | Migrates tool palette tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/node-modification.spec.ts | Migrates node modification tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/model-saving.spec.ts | Migrates model saving tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/model-layout.spec.ts | Migrates model layout tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/model-edit-mode.spec.ts | Migrates edit mode tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/model-data.spec.ts | Migrates model data tests from Chai to Vitest and fixes nested it structure. |
| packages/protocol/src/action-protocol/element-validation.spec.ts | Migrates validation tests from Chai to Vitest and fixes nested it structure. |
| packages/protocol/src/action-protocol/element-type-hints.spec.ts | Migrates type-hints tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/element-text-editing.spec.ts | Migrates text-editing tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/element-selection.spec.ts | Migrates selection tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/element-navigation.spec.ts | Migrates navigation tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/element-hover.spec.ts | Migrates hover tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/element-creation.spec.ts | Migrates creation tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/edge-modification.spec.ts | Migrates edge modification tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/contexts.spec.ts | Migrates contexts tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/clipboard.spec.ts | Migrates clipboard tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/client-notification.spec.ts | Migrates client notification tests from Chai to Vitest. |
| packages/protocol/src/action-protocol/base-protocol.spec.ts | Migrates base protocol tests from Chai to Vitest. |
| packages/protocol/package.json | Removes Mocha/nyc scripts and excludes test assets from packed files. |
| packages/client/tsconfig.test.json | Adds client test-only composite TS config. |
| packages/client/tsconfig.json | Excludes tests from client build outputs. |
| packages/client/src/utils/gmodel-util.spec.ts | Migrates gmodel util tests from Chai to Vitest. |
| packages/client/src/features/validation/marker-navigator.spec.ts | Migrates marker navigator tests from Mocha/Chai to Vitest. |
| packages/client/src/features/tools/marquee-selection/marquee-behavior.spec.ts | Migrates marquee behavior tests from Chai to Vitest. |
| packages/client/src/features/test/layouter-test-util.ts | Removes Mocha dependency and fixes import path for layouter test util. |
| packages/client/src/features/routing/sticky-manhattan-edge-router.spec.ts | Migrates routing tests from Chai to Vitest. |
| packages/client/src/features/navigation/navigation-target-resolver.spec.ts | Migrates navigation resolver tests from Mocha/Chai to Vitest. |
| packages/client/src/features/layout/layout-elements-action.spec.ts | Migrates layout tests to Vitest and removes Sinon usage. |
| packages/client/src/features/grid/grid-snapper.spec.ts | Migrates grid snapper tests from Chai to Vitest. |
| packages/client/src/features/change-bounds/point-position-updater.spec.ts | Migrates point position updater tests from Chai to Vitest. |
| packages/client/src/features/bounds/vbox-layout.spec.ts | Migrates VBox layouter tests to Vitest and uses shared test util module. |
| packages/client/src/features/bounds/hbox-layout.spec.ts | Migrates HBox layouter tests to Vitest and uses shared test util module. |
| packages/client/src/features/bounds/freeform-layout.spec.ts | Migrates FreeForm layouter tests to Vitest and uses shared test util module. |
| packages/client/src/default-modules.spec.ts | Migrates default-modules tests to Vitest and updates spying approach. |
| packages/client/src/base/selection-service.spec.ts | Migrates selection service tests from Chai/Sinon to Vitest mocks/assertions. |
| packages/client/src/base/model/model-initialization-constraint.spec.ts | Migrates model initialization constraint tests from Sinon/Chai to Vitest. |
| packages/client/src/base/model/glsp-model-source.ts | Converts an import to type-only to avoid runtime coupling. |
| packages/client/src/base/feedback/feedback-emitter.spec.ts | Migrates feedback emitter tests from Chai to Vitest. |
| packages/client/src/base/action-dispatcher.spec.ts | Migrates action dispatcher tests from Chai to Vitest. |
| packages/client/package.json | Removes Mocha/nyc scripts and excludes tests from packed files. |
| package.json | Replaces test scripts with Vitest + compile:test, updates Node engine floor, and removes obsolete deps. |
| examples/workflow-standalone/scripts/start.mts | Switches workflow-standalone scripts to .mts and updates imports for ESM/stripping. |
| examples/workflow-standalone/scripts/start-node-server.mts | Switches workflow-standalone server launcher to .mts and updates imports. |
| examples/workflow-standalone/scripts/download-server.mts | Updates download helper for ESM/JSON import attributes and non-require.main entry detection. |
| examples/workflow-standalone/package.json | Updates scripts to run via node (no ts-node). |
| CLAUDE.md | Updates documented test command(s) to Vitest. |
| AGENTS.md | Updates documented test command(s) to Vitest. |
| .vscode/launch.json | Replaces Mocha-based debug launchers with Vitest launchers. |
| .nycrc | Removes obsolete nyc configuration. |
| .mocharc | Removes obsolete Mocha configuration. |
| .gitignore | Removes nyc/CTRF artifacts and broadens tsbuildinfo ignores. |
| .github/workflows/ci.yml | Updates CI to run pnpm test/pnpm test:coverage under Vitest and drops CTRF reporting step. |
| .claude/skills/fix/SKILL.md | Fixes indentation in the /fix skill documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add an afterEach to restore the spy created on container.load, since container.restore() only resets Inversify bindings and would otherwise leave the method permanently spied across tests Part of: eclipse-glsp/glsp#1635
- Rework the ChangeRoutingPointsOperation.create tests so they actually exercise that factory instead of ReconnectEdgeOperation, covering both the defaults and the optional-args cases Part of: eclipse-glsp/glsp#1635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Replaces the Mocha/Chai/nyc/Sinon test stack with Vitest.
@eclipse-glsp/devnext packages, drop.mocharc/.nycrc, and point all test scripts atvitest runtsconfig.test.jsonprojects, since Vitest only transpiles; wire them through acompile:teststep sopnpm testtype-checks specs before running themreflect-metadataonce via root setup files for the DI specsexpectToThrowAsynchelper with Vitest's nativerejects.toThrow()/toThrow()matchers and drop the obsoletetest-utilmoduletest/helper directories from both the build and the packed filespnpm test, and remove the now-obsolete test-report step and the redundant per-package and:citest scripts*.tsbuildinfoso the new per-config build-info is covered, and drop the obsolete nyc/CTRF ignores and clean targetsworkflow-standaloneexample's TS scripts via Node's native type stripping instead ofts-node(which the Mocha toolchain used to provide transitively): convert the scripts to ESM (.mts), drop thets-nodedependency, and raise the Node engine floor to22.18where stripping is unflaggedAlso:
/fixskill docPart of: eclipse-glsp/glsp#1635
How to test
pnpm testtype-checks the specs (compile:test) and runs the full suite under Vitest — 53 test files / 823 tests pass (~2.3s)pnpm compile:testpnpm buildsucceeds with nots-nodeinstalled (workspace or global) — the example's.mtsscripts run under Node's native type strippingpnpm test:coverageproduces the merged coverage reportFollow-ups
None.
Changelog